
//下课
function finishClass(lesson_id,mode){
	var modeType='';
	if(mode==1){
	   modeType=2
	}
	if(mode==2){
	  modeType=4	
	}
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/AttendCourse4Teacher?id=" + lesson_id + '&type=' + modeType ,
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	alert(msg.message);
	    	waitEvaluate();
	    	classInProgress();
	    }
	})
}
//上课
function attendClass(lesson_id,mode){
	var modeType='';
	if(mode==1){
	   modeType=1
	}
	if(mode==2){
	  modeType=3	
	}
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/AttendCourse4Teacher?id=" + lesson_id +  '&type=' + modeType ,
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	alert(msg.message);
	    	classInProgress();
	    	waitClass();
	    }
	})
}
		
//进行中
classInProgress();
function classInProgress(class_id){
	$.ajax({
	    type: 'post',
	    url: ajaxUrl+"/app/course/getCourseListOneTeacher?teacher_id=" + teacherId +"&type=3",
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg)
	    	   var obj={
	    		 code : msg.code,
	    		 message :msg.message,
	    		 data : msg.data.LessonToAttend	   
	    	    }
	    	   $("#jinxingzhong li").remove();
			  if(obj.data.length==""){
				  var addLists=$(
				  	'<li style="padding:30px 0;text-align:center;font-size:16px">' + '暂无课程' + '</li>'
				  )
				  addLists.appendTo($("#jinxingzhong"));
				  $("#ClassListNumbr1").hide();
			  }else{
				for(var i=0;i<obj.data.length;i++){
				  var mode=obj.data[i].mode;
				  var student_name=obj.data[i].student_name;
				  var lesson_name=obj.data[i].lesson_name;
				  var student_avatar=obj.data[i].student_avatar;
				  var class_id=obj.data[i].class_id;
				  var telephone=obj.data[i].telephone;
				  var startTime=obj.data[i].lesson_starttime.time;//上课时间
				  var endTime=obj.data[i].lesson_endtime.time;//下课时间
				  var lesson_id=obj.data[i].lesson_id;
				  
				  var time=String(startTime);//上课时间转换
				  var time1=String(endTime);
				  time=jsonDateFormat(time);//格式化时间
				  time1=jsonDateFormat(time1);//格式化时间
				  if(time1=='未完成'){
						time1='';  
				  }else{
				    time1='-' + time1.substring(11,16);
				  }

				  
				  
				  var modeName="";
				  if(mode==1){
					 modeName="一对一";
				  }else if(mode==2){
					 modeName="小班";
				  }else if(mode==3){
					 modeName="大班";
				  }else{
					 modeName="课程"; 
				  }
				  var gedClassList1 = $(
						  '<li class="boxli">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
						  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>' + '</div>' +
						  '</div>' + '<div class="boxdiv1" style="position:relative">' + '上课时间:' + time + time1 + '</div>' + '</div>' +
						  '<div class="middleList clearfix">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar +  '"/>' + '</div>' + '<div class="boxrightInfo" style="margin-top:8px">' +
						  '<div class="boxspanText">' + student_name + '</div>' + '<div class="boxspanText">' + lesson_name + '</div>' + '</div>' + '<div  class="boxrightInfos2">' + '<span onclick="lessoninf(' + mode + ',' + lesson_id + ',' + "'" + telephone + "'" + ','  + "'" + time + "'" + ',' + "'" + student_avatar + "'" + ',' + "'" + modeName + "'" + ')">' + '<img class="iconBackStyle3" src="' + YHXurl + '/common/img/top_rights.png" >' + '</span>' +
						  '</div>' + '</div>' + '<div class="getOutClass">' + '<span onclick="finishClass(' + "'" + lesson_id + "'" + ',' + mode + ')">' + '下课' + '</span>' + '</div>' + '</div>' + '</li>'
				  )
				  gedClassList1.appendTo($("#jinxingzhong"));
				  $("#ClassListNumbr1").show();
				  $("#ClassListNumbr1").html(obj.data.length);
				} 
			  }
	 			  
	    }
	});
 }

//待上课
waitClass();
function waitClass(){
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/getCourseListOneTeacher?teacher_id=" + teacherId + "&type=2",
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg)
	    	   var obj={
	    		 code : msg.code,
	    		 message :msg.message,
	    		 data : msg.data.LessonToAttend	   
	    	    }
	    	   $("#daishangke li").remove();
	    	  if(obj.data.length==""){
				  var addLists=$(
				  	'<li style="padding:30px 0;text-align:center;font-size:16px">' + '暂无课程' + '</li>'
				  )
				  addLists.appendTo($("#daishangke"));
				  $("#ClassListNumbr2").hide();
			  }else{
				for(var i=0;i<obj.data.length;i++){
				  var mode=obj.data[i].mode;
				  var student_name=obj.data[i].student_name;
				  var lesson_name=obj.data[i].lesson_name;
				  var student_avatar=obj.data[i].student_avatar;
				  var class_id=obj.data[i].class_id;
				  var lesson_id=obj.data[i].lesson_id;
				  var startTime=obj.data[i].lesson_starttime.time;//上课时间
				  var endTime=obj.data[i].lesson_endtime.time;//上课时间
				  var time=String(startTime);//上课时间转换
				  var time1=String(endTime);//上课时间转换
				  time=jsonDateFormat(time);//格式化时间
				  time1=jsonDateFormat(time1);//格式化时间
				  if(time1=='未完成'){
						time1='';  
				  }else{
				    time1='-' + time1.substring(11,16);
				  }
				  
				  var telephone=obj.data[i].telephone;//电话
				  
				  if(!telephone){
					  telephone="电话：" 
				  }
				  var modeName="";
				  if(mode==1){
					 modeName="一对一";
				  }else if(mode==2){
					 modeName="小班";
				  }else if(mode==3){
					 modeName="大班";
				  }else{
					 modeName="课程"; 
				  }
				  

				  var gedClassList2 = $(
						  '<li class="boxli">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
						  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>' + '</div>' +
						  '</div>' + '<div class="boxdiv1" style="position:relative">' + '上课时间:' + time + time1 + '</div>' + '</div>' +
						  '<div class="middleList clearfix">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" />' + '</div>' + '<div class="boxrightInfo">' +
						  '<div class="boxspanText">' + student_name + '</div>' + '<div class="boxspanText">' + lesson_name + '</div>' + '<div class="boxspanText">' + '<a href="tel:"' + telephone + '>' + telephone + '<img src="' + YHXurl + '/common/img/telephoneIco1.png" class="telImg"/>' + '</a>' + '</div>' + '</div>' + '<div  class="boxrightInfos2">' + '<span onclick="lessoninf(' + mode + ',' + lesson_id + ',' + "'" + telephone + "'" + ','  + "'" + time + "'" + ',' + "'" + student_avatar + "'" + ',' + "'" + modeName + "'" + ')">' + '<img class="iconBackStyle3" src="' + YHXurl + '/common/img/top_rights.png">' + '</span>' +
						  '</div>' + '</div>' + '<div class="getOutClass">' + '<span onclick="attendClass(' + "'" + lesson_id + "'" + ',' + mode + ')">' + '上课' + '</span>' + '</div>' + '</div>' + '</li>'
				  )
				  gedClassList2.appendTo($("#daishangke"));
				  $("#ClassListNumbr2").show();
				  $("#ClassListNumbr2").html(obj.data.length);
				}  
			  }
	 			  
	    }
	});
 }



//未排课
notDischargingCourse();
function notDischargingCourse(){
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/getCourseListOneTeacher?teacher_id=" + teacherId + "&type=1",
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg)
	    	   var obj={
	    		 code : msg.code,
	    		 message :msg.message,
	    		 data : msg.data.UnArrangedClassList4Teacher	   
	    	    }
	    	   $("#weipaike li").remove();
	    	   if(obj.data.length==""){
					  var addLists=$(
					  	'<li style="padding:30px 0;text-align:center;font-size:16px">' + '暂无课程' + '</li>'
					  )
					  addLists.appendTo($("#weipaike"));
					  $("#ClassListNumbr3").hide();
				  }else{
					for(var i=0;i<obj.data.length;i++){
					  var mode=obj.data[i].mode;
					  var teach_type=obj.data[i].teach_type;
					  var student_name=obj.data[i].student_name;
					  var telephone=obj.data[i].telephone;
					  var class_name=obj.data[i].class_name;
					  var student_avatar=obj.data[i].student_avatar;
					  //var class_id=obj.data[i].class_id//课程ID
					  var buy_num=obj.data[i].buy_num;
					  var arrange_num=obj.data[i].arrange_num;
					  //var lesson_id=obj.data[i].lesson_id;
					  var class_id=obj.data[i].class_id;
					  var order_id=obj.data[i].order_id;
					  var student_id=obj.data[i].student_id;

					  
					  var classTypeText="";
					  if(teach_type==1){
						  classTypeText="学生上门";
					  }else if(teach_type==2){
						  classTypeText="老师上门";
					  }else if(teach_type==3){
						  classTypeText="教学中心";
					  }
					  
					  var modeName="";
					  if(mode==1){
						 modeName="一对一";
					  }else if(mode==2){
						 modeName="小班";
					  }else if(mode==3){
						 modeName="大班";
					  }else{
						 modeName="课程"; 
					  }
					  var gedClassList3 = $(
							  '<li class="boxli" style="border-bottom: 1px solid #979797">' + 
							  '<span onclick="paikeList('+ class_id + ',' + order_id + ',' + student_id + ',' + "'" + student_name + "'" + ',' + "'" + student_avatar + "'"  + ',' + arrange_num +')">' +
							  '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
							  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>'  + '</div>' +
							  '</div>' + '<div class="boxdiv1" style="position:relative">' + '上课时间:'  + '未设置' +  '<span class="bmks">' + arrange_num + '/' + buy_num + '(已排课/总课时)' + '</span>' + '</div>' + '</div>' +
							  '<div class="middleList clearfix">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" />' + '</div>' + '<div class="boxrightInfo">' +
							  '<div class="boxspanText">' + student_name + '<span style="margin-left:10px">(' + classTypeText + ')</span>' + '</div>' + '<div class="boxspanText">' + class_name + '</div>' + '<div class="boxspanText">' + '<a href="tel:"' + telephone + '>' + telephone + '<img src="' + YHXurl + '/common/img/telephoneIco1.png" class="telImg"/>' + '</a>' +'</div>'  + '</div>' + '<div  class="boxrightInfos2">' + '<a href="">' + '<img class="iconBackStyle3" src="' + YHXurl + '/common/img/top_rights.png">' + '</a>' +
							  '</div>' + '</div>' + '</div>' + '</a>' + '</li>'
							  
							  
					  )
					  gedClassList3.appendTo($("#weipaike"));
					  $("#ClassListNumbr3").show();
					  $("#ClassListNumbr3").html(obj.data.length);
					}   
			}
	 			  
	    }
	});
 }



//待评价
waitEvaluate();
function waitEvaluate(){
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/getCourseListOneTeacher?teacher_id=" + teacherId + "&type=4",
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg)
	    	   var obj={
	    		 code : msg.code,
	    		 message :msg.message,
	    		 data : msg.data.StudentToEvaluate	   
	    	    }
	    	   $("#daipingjia li").remove();
	    	  if(obj.data.length==""){
				  var addLists=$(
				  	'<li style="padding:30px 0;text-align:center;font-size:16px">' + '暂无课程' + '</li>'
				  )
				  addLists.appendTo($("#daipingjia"));
				  $("#ClassListNumbr4").hide();
			  }else{
				for(var i=0;i<obj.data.length;i++){
				  var mode=obj.data[i].mode;
				  var student_name=obj.data[i].student_name;
				  var lesson_name=obj.data[i].lesson_name;
				  var student_avatar=obj.data[i].student_avatar;//学生头像
				  var class_id=obj.data[i].class_id;//
				  var student_id=obj.data[i].student_id//学生Id
				  var lesson_id=obj.data[i].lesson_id//课节ID
				  var startTime=obj.data[i].lesson_starttime.time;//
				  var endTime=obj.data[i].lesson_endtime.time;//
				  var time=String(startTime);//上课时间转换
				  var time1=String(endTime);
				  time=jsonDateFormat(time);//格式化时间
				  time1=jsonDateFormat(time1);//格式化时间
				  if(time1=='未完成'){
						time1='';  
				  }else{
				    time1='-' + time1.substring(11,16);
				  }
				  
				
				  
				  var modeName="";
				  if(mode==1){
					 modeName="一对一";
				  }else if(mode==2){
					 modeName="小班";
				  }else if(mode==3){
					 modeName="大班";
				  }else{
					 modeName="课程"; 
				  }
				  var gedClassList4 = $(
						  '<li class="boxli">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
						  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>' + '</div>' +
						  '</div>' + '<div class="boxdiv1" style="position:relative">' + '上课时间:' + time + time1 + '</div>' + '</div>' +
						  '<div class="middleList clearfix">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" />' + '</div>' + '<div class="boxrightInfo" style="margin-top:8px">' +
						  '<div class="boxspanText">' + student_name + '</div>' + '<div class="boxspanText">' + lesson_name + '</div>' + '</div>' + '<div  class="boxrightInfos2" style="width:auto">' +  '<span class="pingjiaBtn" onclick="pingjia('+ teacherId + ',' + student_id + ',' + lesson_id + ','  + "'" + student_avatar +  "'" + ',' + "'" + student_name + "'" + ')">'  + '评价'  + '</span>' +
						  '</div>' + '</div>' + '</div>' + '</li>'
				  )
				  gedClassList4.appendTo($("#daipingjia"));
				  $("#ClassListNumbr4").show();
				  $("#ClassListNumbr4").html(obj.data.length);
				} 
			  }
	 			  
	    }
	});
 }


//已完成
var completeClass=function(){
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/getCourseListOneTeacher?teacher_id=" + teacherId + "&type=5",
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg)
	    	   var obj={
	    		 code : msg.code,
	    		 message :msg.message,
	    		 data : msg.data.DoneClassList4Teacher	   
	    	    }
	    	   $("#yiwancheng li").remove();
	    	  if(obj.data.length==""){
				  var addLists=$(
				  	'<li style="padding:30px 0;text-align:center;font-size:16px">' + '暂无课程' + '</li>'
				  )
				  addLists.appendTo($("#yiwancheng"));
				  $("#ClassListNumbr5").hide();
			  }else{
				for(var i=0;i<obj.data.length;i++){
				  var mode=obj.data[i].mode;//课程类型
				  var student_name=obj.data[i].student_name;//学生名字
				  var class_name=obj.data[i].class_name;//课程名字
				  var student_avatar=obj.data[i].student_avatar;//学生头像
				  var class_id=obj.data[i].class_id;//课程ID
				  var student_id=obj.data[i].student_id;//学生ID
				  var order_id=obj.data[i].order_id;//课节ID
				  var orderNo=obj.data[i].orderNo;//订单号
				  var class_progress=obj.data[i].class_progress;//进度
				  var startTime=obj.data[i].class_starttime.time;//上课时间
				  var endTime=obj.data[i].class_endtime.time;//下课时间
				  var class_progress=obj.data[i].class_progress;//课程进度
				  var time=String(startTime);
				  var time1=String(endTime);
				  time=jsonDateFormat(time);//格式化时间
				  time1=jsonDateFormat(time1);//格式化时间
				  if(time1=='未完成'){
						time1='';  
				  }else{
				    time1='-' + time1.substring(11,16);
				  }
				  
				  var modeName="";
				  if(mode==1){
					 modeName="一对一";
				  }else if(mode==2){
					 modeName="小班";
				  }else if(mode==3){
					 modeName="大班";
				  }else{
					 modeName="课程"; 
				  }
				  var gedClassList5 = $(
						  '<li class="boxli" style="border-bottom: 1px solid #979797">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
						  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>'  + '</div>' +
						  '</div>' + '<div class="boxdiv1" style="position:relative">' + '订单号:' + orderNo + '</div>' + '</div>' +
						  '<div class="middleList clearfix">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" />'  + '</div>' + '<div class="boxrightInfo copInfo" style="margin-top:0">' +
						  '<div class="boxspanText">' + student_name + '<span style="margin-left:10px">' +  class_progress  + '</span>' + '</div>' +'<div class="boxspanText">' + '报名时间:' + time + time1 + '</div>'  + '</div>' + '<div  class="boxrightInfos2">' + '<span onclick="lessonData(' + student_id + ',' + class_id + ',' + order_id + ',' + "'" + student_avatar + "'" + ')">' + '<img class="iconBackStyle3" src="' + YHXurl + '/common/img/top_rights.png">' + '</span>' +
						  '</div>' + '</div>' + '</div>' + '</li>'
				  )
				  gedClassList5.appendTo($("#yiwancheng"));
				  $("#ClassListNumbr5").show();
				  $("#ClassListNumbr5").html(obj.data.length);
				}
			  }
	 			  
	    }
	});
} 
//已完成详细页面
function lessonData(student_id,class_id,order_id,student_avatar){
	$(document).scrollTop(0);
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/getCourseInfDetail4Teacher?student_id=" + student_id + '&class_id=' + class_id + '&order_id=' + order_id,
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg);
	    	$("#completedDetailed").show();
	    	$("#comMessage ul").remove();
	    	$("#com_pj_list li").remove();
	    	var obj={
		    	code : msg.code,
		    	message :msg.message,
		        data : msg.data.classinf4teacher	   
		    }
	    	  var mode=obj.data.mode;//课程类型
			  var student_name=obj.data.student_name;//学生名字
			  var class_name=obj.data.class_name;//课程名字
			  //var student_avatar=obj.data.student_avatar;//学生头像
			  var order_seq=obj.data.order_seq;//订单号
			  var class_time_str=obj.data.class_time_str;//上课时间
			  var order_cdate=obj.data.order_cdate;
			 			  
			  var modeName="";
			  if(mode==1){
				 modeName="一对一";
			  }else if(mode==2){
				 modeName="小班";
			  }else if(mode==3){
				 modeName="大班";
			  }else{
				 modeName="课程"; 
			  }
			  
			  
			  
			  var gedClassList5 = $(
					  '<ul style="border-bottom:10px solid #f2f2f2;padding-bottom:10px;" class="ul1">' +
					  '<li class="boxli">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
					  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>'  + '</div>' +
					  '</div>' + '<div class="boxdiv1" style="position:relative">' + '订单号:' + order_seq + '</div>' + '</div>' +
					  '<div class="middleList clearfix" style="margin-top:10px">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" />'  + '</div>' + '<div class="boxrightInfo copInfo" style="margin-top:10px">' +
					  '<div class="boxspanText">' + student_name + '<span style="margin-left:10px">' +  '' + '</span>' + '</div>' + '<div class="boxspanText">' + '报名时间:' + class_time_str + '</div>'  + '</div>' + '<div  class="boxrightInfos2">'  +
					  '</div>' + '</div>' + '</div>' + '</li>' + '</ul>' 
				
			  )
			  gedClassList5.appendTo($("#comMessage"));
			  
			  
			  var comArr=obj.data.lessonlist4teacher;
			  for(var i=0;i<comArr.length;i++){
				var lesson_eva_assess=comArr[i].lesson_eva_assess;
				var lesson_eva_content=comArr[i].lesson_eva_content;
				var lesson_name=comArr[i].lesson_name;
				var _lesson_time_str=comArr[i].lesson_time_str;
				var sequence=comArr[i].sequence;
			    var comPjList=$(
				  '<li>' + '<div class="conwrap">' + '<div>' + '<span class="n">' + sequence + '</span>' + '<span style="margin-left:15px">' + lesson_name + '</span>' + '<span style="margin-left:10px">' + _lesson_time_str + '</span>' + '</div>' +
				  '<div class="cont">' + '<span class="eal">' + lesson_eva_assess + '</span>' + '<span style="margin-left:15px">' + lesson_eva_content + '</span>' + '</div>' + '</div>'
			    );
			    
			    comPjList.appendTo($("#com_pj_list"));
			  }
			  
			  
	    	}

	    	
	   
	})
}


//待排课列表
completeClass();
function paikeList(class_id,order_id,student_id,student_name,student_avatar,arrange_num){
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/getUnArrangedLesson?class_id=" + class_id + "&order_id=" + order_id + "&student_id=" + student_id,
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	console.log(msg)
	    	var obj={
		    		 code : msg.code,
		    		 message :msg.message,
		    		 data : msg.data.UnArrangedLessonList4Teacher	   
		    	    }
	    	$("#paikeList li").remove();
	    	$(".paikeListWrap").show();
	    	
	    	
	    	for(var i=0;i<obj.data.length;i++){
				  var mode=obj.data[i].mode;//课程类型
				  var lesson_name=obj.data[i].lesson_name;//课节名称
				  //var student_avatar=obj.data[i].student_avatar;//学生头像
				  var class_id=obj.data[i].class_id;//课程ID
				  var lesson_id=obj.data[i].lesson_id;//课节ID
				  var sequence=obj.data[i].sequence;//课节序列号
				  var startTime=obj.data[i].lesson_starttime.time;//上课时间
				  var endTime=obj.data[i].lesson_endtime.time;//上课时间
				  var time=String(startTime);//上课时间转换
				  var time1=String(endTime);
				  time=jsonDateFormat(time);//格式化时间
				  time1=jsonDateFormat(time1);//格式化时间
				  
				  if(time=="未完成"){
					  time="未设置";
				  }
				  
				  if(time1=='未完成'){
						time1='';  
				  }else{
				    time1='-' + time1.substring(11,16);
				  }
				  var setTimestr='';
				  var setStius='';
				  var setStr1='<div class="timebtn2">' + '<img src="' + YHXurl + '/common/img/setOk.png" height="15">' + '已设置' + '</div>';
				  var setStr2='<div onclick="showSlectLesson(' + lesson_id + ',' + 'this' + ')"' +  'class="timebtn">' + '设置上课时间' + '</div>';
				  if(i>=arrange_num){
					  setTimestr=setStr2; 
					  setStius="未设置";
				  }else{
					  setTimestr=setStr1;
					  setStius="已设置";
				  }
				  var gedClassList5 = $(
		    			  '<li class="boxli">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
		    			  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + '一对一' + '</strong>' + '</div>' +
		    			  '</div>' + '<div class="boxdiv1" style="position:relative">' + '上课时间:' + '<span class="okTime">' + time + time1 + '</span>' +  '</div>' + '</div>' +
		    			  '<div class="middleList clearfix">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" />' + '</div>' + '<div class="boxrightInfo copInfo" style="margin-top:8px">' +
		    			  '<div class="boxspanText">' + student_name + '</div>' + '<div class="boxspanText">' + lesson_name + '' + '</div>' + '</div>' + '<div  class="boxrightInfos2">' + setTimestr + '</div>' + '<span class="num">' + sequence + '</span>' +
		    			  '</div>' + '</div>' + '</div>' + '</li>'
		    	  )
		    	  gedClassList5.appendTo($("#paikeList"));
				  
		    	}
	    	} 
	    	

	    
	})  
	
	
	
	
}



//课节详情
function lessoninf(mode,lesson_id,telephone, time ,student_avatar, modeName){
	$("#lessonInfList li").remove();
	$(".lessonInfWrap").show();
	$(document).scrollTop(0);
	if(mode==1){
		$.ajax({
		    type: 'post',
		    url:ajaxUrl + "/app/course/getLessonInf?lesson_id=" + lesson_id,
		    data:'',//传给后台的数据，多个参数用&连接
		    dataType: 'JSON',
		    cache:false,
		    success: function(msg){
		    	console.log(msg);
		    	var obj={
			      code : msg.code,
			      message :msg.message,
			      data : msg.data.lessoninf	   
			    	    }
		    	var lesson_name=obj.data.lesson_name;
		    	var t_name=obj.data.t_name;
		    	var order_seq=obj.data.order_seq;
		    	var teach_type=obj.data.teach_type;
		    	var lessoninfList=$(
		    			'<li class="boxli">' + '<div class="box clearfix">' + '<div class="topList clearfix" >' + 
		    			  '<div class="boxdiv">' + '<div class="boxdiv11">' + '<strong >' + modeName + '</strong>' + '</div>' +
		    			  '</div>'  + '</div>' + '</div>' +
		    			  '<div class="middleList clearfix" style="padding-top:10px">' + '<div class="boxleftInfos clearfix">' + '<img class="avatar2 photoStyle2" src="' + student_avatar + '" style="height:auto"/>' + '</div>' + '<div class="boxrightInfo copInfo">' +
		    			  '<div class="boxspanText" style="margin-top:8px">' + '姓名' + t_name + '</div>' + '<div class="boxspanText">' + '课程名:' + lesson_name + '</div>' + '</div>' + '<div  class="boxrightInfos2">'  +
		    			  '</div>' + '</div>' + '</div>' + '<div class="lessonDataList">' + 
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '订单号' + '</span>' + order_seq + '</div>' + 
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '上课时间' + '</span>' + time + '</div>' +
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '上课方式' + '</span>' + modeName + '</div>' +
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '学生电话' + '</span>' + '<a href="tel:' + telephone + '">' + telephone + '<img src="' + YHXurl + '/common/img/telephoneIco1.png" class="telImg"/>' + '</a>' + '</div>' +
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '授课方式' + '</span>' + teach_type + '</div>' +
		    			  '</li>'
		    	)
		    	lessoninfList.appendTo($("#lessonInfList"));
		    }
		})
	}
	
	if(mode==2||mode==3){
		$.ajax({
		    type: 'post',
		    url:ajaxUrl + "/app/course/getBankeLessonInf?lesson_id=" + lesson_id ,
		    data:'',//传给后台的数据，多个参数用&连接
		    dataType: 'JSON',
		    cache:false,
		    success: function(msg){
		    	console.log(msg);
		    	var obj={
			     code : msg.code,
				 message :msg.message,
				 data : msg.data.lessoninf	   
				}
		    	var class_address=obj.data.class_address;
		    	var lesson_name=obj.data.class_name;
		    	var student_list=obj.data.student_list;
		    	var student_listStr='';
		    	for(var i=0;i<student_list.length;i++){
		    		student_listStr+=student_list[i].username ;
		    	}
		    	var lessoninfList=$(
		    			'<li class="boxli">' + '<div class="lessonDataList" style="border:none;padding-top:0">' + 
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '课程名称' + '</span>' + lesson_name + '</div>' + 
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '上课时间' + '</span>' + time + '</div>' +
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '报名学生' + '</span>' + student_listStr + '</div>' +
		    			  '<div class="lessonDataNum">' + '<span class="t">' + '上课地点' + '</span>' + class_address + '</div>' +
		    			  '<li>'
		    	)
		    	lessoninfList.appendTo($("#lessonInfList"));
		    }
		})
	}
}





//生成评价页面
function pingjia(teacherId,student_id,lesson_id,student_avatar,student_name){
	 n=0;
	if(student_avatar){
		var student_avatar=student_avatar;
	}else{
		var student_avatar="http://www.yihaoxue.net/webapp/common/img/yihaoxue.png";
	}
	$(".pingjiaWrap").show();
	$(document).scrollTop(0);
	$("boyd").css({"overflow-y" : "hidden"})
	$("#pingjiaList .pingjiaOuer").remove();
	var pingjia=$(
			'<div class="pingjiaOuer">' + '<div class="ul">' + '<div class="li1">' + '<p class="photo">' + '<img class="avatar photoStyle1" src="' + student_avatar + '" >' +
			'<p class="name">' + student_name + '</p>' + '</div>' + '<div class="li2">' + '<p class="pf">' + '老师评分：' + '<input type="number" data-role="none" class="pf_input" disabled="disabled">' + 
			'<p class="xing">' + 
			'<img src="' + YHXurl + '/common/img/pingjia1.png" height="25" onclick="pingfen(this)">' + 
			'<img src="' + YHXurl + '/common/img/pingjia1.png" height="25" onclick="pingfen(this)">' +
			'<img src="' + YHXurl + '/common/img/pingjia1.png" height="25" onclick="pingfen(this)">' + 
			'<img src="' + YHXurl + '/common/img/pingjia1.png" height="25" onclick="pingfen(this)">' +
			'<img src="' + YHXurl + '/common/img/pingjia1.png" height="25" onclick="pingfen(this)">' +
			'</p>' + '</div>' + '</div>' + '<div class="teacher_text clearfix">' + '<div class="title clearfix">' + '<img src="' + YHXurl + '/common/img/advice.png" height="24">' +
			'老师评语:' + '</div>' + '<textarea name="" cols="" rows="6" data-role="none"  style="height:200px;width:100%;border:none;" id="pingjiaTxr">' + '</textarea>' + ' <div class="adviceBtn">' + 
			'<input data-role="none" type="button" value="发表" class="l_btn" style="width:100%" onclick="fabiaoPingjia(' + teacherId + ',' + student_id + ',' + lesson_id + ')"/>' + '</div>' + '</div>' + '</div>'
			)
	pingjia.appendTo($("#pingjiaList"));
	 $(".pf_input").val(n);
}





//发表评价
function fabiaoPingjia(teacherId,student_id,lesson_id){
	var evaluate_note='';
	var evaluate_assess= n;
	if($("#pingjiaTxr").val()!=''){
	   evaluate_note=$("#pingjiaTxr").val();
	}else{
		alert("请填写评语");
		return;
	}
	if(evaluate_assess==0){
		alert("请评分");
		return;
	}
	
	$.ajax({
	    type: 'post',
	    url: ajaxUrl + "/app/course/evaluatestudent?teacher_id=" + teacherId + '&student_id=' + student_id + '&lesson_id=' + lesson_id + '&evaluate_note=' + encodeURI(encodeURI( evaluate_note)) + '&evaluate_assess=' + evaluate_assess,
	    data:'',//传给后台的数据，多个参数用&连接
	    dataType: 'JSON',
	    cache:false,
	    success: function(msg){
	    	alert(msg.message);
	    	$(".pingjiaWrap").hide();
	    	waitEvaluate();
	    	completeClass();
	    }
	})
}

//评价分数
var n=0;
function pingfen(_this){
	var _this=$(_this);
	var src1=YHXurl + "/common/img/pingjia1.png";
	var src2=YHXurl + "/common/img/pingjia2.png";
	_this.toggleClass("on");
		 _this.attr("src",src2);
		 _this.prevAll().attr("src",src2);
		 n=_this.index()+1;
		 $(".pf_input").val(n);
		 _this.nextAll().attr("src",src1);
	
}



$("#closePK").on("click",function(){
	$(".classCalendar").hide();
})

	$(function(){
		$("#nav ul li").click(function(){
			$(this).siblings().removeClass("on_active");
			$(this).addClass("on_active");
			if($(this).index()==""){
				classInProgress();
			}
			if($(this).index()==1){
				waitClass();
			}
			if($(this).index()==2){
				notDischargingCourse();
			}
			if($(this).index()==3){
				waitEvaluate()
			}
			if($(this).index()==4){
				completeClass()
			}
	        $(".yhxCourseWrap").hide().eq($('#nav ul li').index(this)).show();
		});
	});
	function closepaike(){
		$(".paikeListWrap").hide()
	}
	function closepingjia(){
		$(".pingjiaWrap").hide();
		$(".pf_input").val("");
	}
	$("#closeLesInf").on("click",function(){
		$(".lessonInfWrap").hide();
	})
	function closecompletedDetailed(){
		$("#completedDetailed").hide()
	}
	
	
	function closeClassCalendar(){
		window.location.href=window.location.href;
		$(".ui-page").css({"overflow-y":"inherit"});
	}
	function prevDate(){calender.changeDate(-7);}//更新日期
	function nextDate(){calender.changeDate(7);}//更新日期
	
	
	 /**
	  * 时间对象的格式化
	  */
	function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式
	     try {
	    	 if(jsonDate==0){
	    		 return "未完成";
	    	 }
	         var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
	         var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
	         var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
	         var hours = date.getHours();
	         if(hours<10){
	        	 hours='0' + hours;
	         }
	         var minutes = date.getMinutes();
	         if(minutes<10){
	        	 minutes=minutes + "0";
	         }
	         var seconds = date.getSeconds();
	         var milliseconds = date.getMilliseconds();
	         return date.getFullYear() + "-" + month + "-" + day + " " + hours + ":" + minutes;//+ ":" + seconds + '0' + ":" + milliseconds + '0'
	     } catch (ex) {
	         return "";
	     }
	 }	
